<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>销售汇总打印</title>
    <script src="/jquery-1.8.3.min.js"></script>
    <script src="/printThis.js"></script>
    <script src="/chineseMoney.js"></script>
    <script src="/tools.js"></script>
    <link rel="stylesheet" href="/print.css"/>
</head>
<body>
<div id="receiptPrintArea0">
    <h3 style="text-align: center">销售汇总<span class="originalProcess"></span></h3>
    <br/>
    <table width="100%">
        <tr>
            <td width="25%">配送日期：</td><td width="75%"><span class="supplyDate"></span></td>
        </tr>
        <tr>
            <td width="25%">食材分类：</td><td width="75%"><span class="type"></span></td>
        </tr>
        <tr>
            <td width="25%">合计金额：</td><td width="75%"><span class="total"></span></td>
        </tr>
    </table>
    <br/>
    <table style="width: 100%;" class="printTable">
        <thead style="border: 1px solid">
        <td width="30%">名称</td>
        <td width="15%">规格</td>
        <td width="15%">品牌</td>
        <td width="10%">单位</td>
        <td width="15%">数量</td>
        <td width="15%">金额</td>
        </thead>
        <tbody id="content">
        </tbody>
    </table>
</div>
<script th:inline="javascript">
    var params = [[${params}]];
    var backAddress = params.backAddress;
    var beginSupplyDate = params.beginSupplyDate;
    var endSupplyDate = params.endSupplyDate;
    var foodMaterialType = params.foodMaterialType;
    var foodMaterialTypeName = params.foodMaterialTypeName;
    var originalProcess = params.originalProcess ;
    function print() {
        $("#receiptPrintArea0").printThis({
            debug: false,
            importCSS: true,
            importStyle: true,
            printContainer: true,
            pageTitle: "",
            removeInline: false,
            printDelay: 333,
            header: null,
            formValues: true
        });
    }
    $.ajax({
        url: backAddress + "/api/financial/querySaleSummary",
        contentType: "application/json;charset=utf-8",
        data : JSON.stringify({
            "beginSupplyDate" : beginSupplyDate,
            "endSupplyDate" : endSupplyDate,
            "foodMaterialType" : foodMaterialType,
            "originalProcess" : originalProcess,
            "pageNo" : 1,
            "pageSize" : 2000
        }),
        type: "post",
        dataType: "json",
        success: function (data) {
                //console.log(data)
            $(".supplyDate")[0].innerText = beginSupplyDate + '至' + endSupplyDate;
            $(".type")[0].innerText = foodMaterialTypeName;
            $(".originalProcess")[0].innerText = getOriginalProcess(originalProcess);
            var str = '' ;
            var total = 0 ;
            for (var i = 0 ; i < data.data.page.list.length ; i++) {
                str = "<tr><td width=\"30%\">" + data.data.page.list[i].foodMaterialName + "</td>" +
                            "<td width=\"15%\">" + dealNull(data.data.page.list[i].specs) + "</td>" +
                            "<td width=\"15%\">" + dealNull(data.data.page.list[i].brand) + "</td>" +
                            "<td width=\"10%\">" + dealNull(data.data.page.list[i].unitName) + "</td>" +
                            "<td width=\"15%\">" + data.data.page.list[i].totalAmount + "</td>" +
                            "<td width=\"15%\">" + data.data.page.list[i].total + "</td></tr>" ;
                $("#content").append($(str));
                total += data.data.page.list[i].total * 100 ;
            }
            $(".total")[0].innerText = total / 100 ;
            print()
        },
        error: function (status) {
                alert(status)
        }
    })
</script>
</body>
</html>